package cn.wizzer.app.user.modules.models;


import cn.wizzer.app.user.modules.models.enums.BizTypeEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.integration.json4excel.annotation.J4EIgnore;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("user_account_record")
@Comment("用户流水表")
@TableIndexes({@Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false),
        @Index(name = "index_userId_and_bizType", fields = {"userId", "bizType"}, unique = false),
        @Index(name = "index_userId_and_bizType_and_bizId", fields = {"userId", "bizType", "bizId"}),
        @Index(name = "index_bizId_and_bizType", fields = {"bizId", "bizType"}, unique = false)})
public class UserAccountRecord extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @J4EIgnore
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Column
    @Comment("币种")
    @ColDefine(type = ColType.VARCHAR, width = 32,notNull = true)
    private String currencyId;

    @Column
    @Comment("操作金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal amount;

    @Column
    @Comment("操作后可用余额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal balance;


    @Column
    @Comment("业务类型")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private BizTypeEnum bizType;

    @Column
    @Comment("业务关联ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String bizId;

    @Column
    @Comment("业务orderNo")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String bizNo;

    @Column
    @Comment("创建时间")
    //Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
    private Long ctAt;

    @Column
    @Comment("统计状态")
    @ColDefine(type = ColType.BOOLEAN, width = 32)
    @Default("0")
    private Boolean counted;

}
